<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${orderSpecs.id}" type="hidden">
<!--                        <input id="post" name="post" th:value="${orderSpecs.post}" type="hidden">-->
                        <div class="form-group">
                            <label class="col-sm-3 control-label">开票状态：</label>
                            <input id="stateHidden" th:value="${orderSpecs.stateMoney}" class="form-control"
                                   type="hidden">
                            <div class="col-sm-8">
                                <select name="stateMoney" id="stateMoney">
                                    <option value="">请选择</option>
                                    <option value="2">未开票</option>
                                    <option value="3">已开票</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">收款状态：</label>
                            <input id="collection" th:value="${orderSpecs.stateCollection}" class="form-control"
                                   type="hidden">
                            <div class="col-sm-8">
                                <select name="stateCollection" id="stateCollection">
                                    <option value="">请选择</option>
                                    <option value="0">未审核</option>
                                    <option value="1">未收款</option>
                                    <option value="2">已收款</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">预收款：</label>
                            <div class="col-sm-8">
                                <input id="advancePayment" th:value="${orderSpecs.advancePayment}" name="advancePayment"
                                       placeholder="输入预收款金额（选填）" class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">实际收款：</label>
                            <div class="col-sm-8">
                                <input id="actualMoney" th:value="${orderSpecs.actualMoney}" name="actualMoney"
                                       placeholder="输入实际收款金额" class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">退款状态：</label>
                            <input id="refundStateHidden" th:value="${orderSpecs.refundState}" class="form-control"
                                   type="hidden">
                            <div class="col-sm-8">
                                <select name="refundState" id="refundState">
                                    <option value="">请选择</option>
                                    <option value="0">未审核</option>
                                    <option value="1">未退款</option>
                                    <option value="2">已退款</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">退款金额：</label>
                            <div class="col-sm-8">
                                <input id="refundMoney" th:value="${orderSpecs.refundMoney}" name="refundMoney"
                                       placeholder="输入实际退款金额" class="form-control" type="text">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <textarea name="stateMoneyMark" th:text="${orderSpecs.stateMoneyMark}" maxlength="250"
                                          style="height:300px" class="form-control" id="stateMoneyMark"
                                          placeholder="审核未通过请输入备注(最多输入200字)"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script src="/js/jquery.citys.js"></script>
<script src="//s.xlongwei.com/res/js/My97DatePicker/WdatePicker.js"></script>
<!--<script type="text/javascript" src="/js/webJs/jzweb/bookOrder/editCw.js">-->
<!--</script>-->
<script>
    $().ready(function () {

        $("#stateMoney").val($("#stateHidden").val());

        $("#stateCollection").val($("#collection").val());

        $("#refundState").val($("#refundStateHidden").val());

        validateRule();
    });

    $.validator.setDefaults({
        submitHandler: function () {
            update();
        }
    });

    function update() {

        $.ajax({
            cache: true,
            type: "POST",
            url: "/jzweb/orderSpecs/update",
            data: JSON.stringify({
                id:$('#id').val(),
                stateMoney:$('#stateMoney').val(),
                stateCollection:$('#stateCollection').val(),
                advancePayment:$('#advancePayment').val(),
                actualMoney:$('#actualMoney').val(),
                refundState:$('#refundState').val(),
                refundMoney:$('#refundMoney').val(),
                stateMoneyMark:$('#stateMoneyMark').val()
            }),
            async: false,
            contentType: "application/json",
            error: function (request) {
                parent.layer.alert("Connection error");
            },
            success: function (data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    parent.reLoad();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);

                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });

    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            // rules : {
            // 	actualMoney : {
            // 		required : true
            // 	}
            // },
            // messages : {
            // 	actualMoney : {
            // 		required : icon + "请输入实际收款金额"
            // 	}
            // }
        })
    }
</script>
<script>
    $(function () {
        //获取用户信息
        //省市区联动
        $('#adre').citys({
            province: $("#province").val(),
            city: $("#city").val(),
            district: $("#district").val(),
            onChange: function (info) {
            }
        });
    });
</script>
</body>
</html>
